import cv2 as cv
import numpy as np


def nothing_call(self):
    pass


src = np.zeros([300,500,3],np.uint8)
cv.namedWindow('image',cv.WINDOW_AUTOSIZE)
cv.createTrackbar('R','image',0,255,nothing_call)
cv.createTrackbar('G','image',0,255,nothing_call)
cv.createTrackbar('B','image',0,255,nothing_call)
swith_txt = 'Swith:0:OFF 1:ON'
cv.createTrackbar(swith_txt,'image',1,1,nothing_call)
while True:
    cv.imshow('image',src)
    key = cv.waitKey(1)
    if key == 27:
        break
    r = cv.getTrackbarPos('R','image')
    g = cv.getTrackbarPos('G', 'image')
    b = cv.getTrackbarPos('B', 'image')
    s = cv.getTrackbarPos(swith_txt, 'image')
    if np.int(s) == 0:
        src[:] = 0
    else:
        src[:] = [b,g,r]
cv.destroyAllWindows()
